﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
#if !NETCOREAPP
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages;
    using System.Web.Mvc.Html;

#endif

#if NETCOREAPP
using Microsoft.AspNetCore.Mvc.Rendering;
using Kugar.Core.Web;
#endif

namespace Kugar.MVC.MobileUI.WeUI.PageControls.PageForm
{
    /// <summary>
    /// 验证码图片控件
    /// </summary>
    public class PageForm_VCode:PageForm_FieldBase
    {
        private string _imgUrl = "";
        private string _placeHolder = "请输入验证码";
        private string _value = "";

        public PageForm_VCode(ViewContext viewContext) : base(viewContext)
        {
            _attrs.Class("weui-cell_vcode");
        }

        public PageForm_VCode ImageUrl(string imgUrl)
        {
            _imgUrl = imgUrl;

            return this;
        }

        public PageForm_VCode Value(string value)
        {
            _value = value;

            return this;
        }

        public PageForm_VCode Placeholder(string text)
        {
            _placeHolder = text;

            return this;
        }


        protected override void RenderBody()
        {
            ViewContext.Writer.WriteLine($"<input class=\"weui-input\" required type=\"text\" name=\"{_name}\" placeholder=\"{_placeHolder}\" value=\"{_value}\" />");
        }

        protected override void RenderFooter()
        {
            ViewContext.Writer.WriteLine($"<img class=\"weui-vcode-img\" src=\"{_imgUrl}\" />");

            base.RenderFooter();
        }
    }
}